package com.itboye.ihomebank.activity.me;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.presenter.KeyPresenter;
import com.itboye.ihomebank.util.ByAlert;
import com.itboye.ihomebank.util.SPUtils;

import java.util.Observable;
import java.util.Observer;
/**
 * 反馈
 *
 */
public class ActivityFanKui extends BaseOtherActivity implements Observer{
	View v_statusbar;
	ImageView close_icon;
	TextView add_shap_title_tv;
	EditText fankui_et;
	TextView fankui_ok;
	
	KeyPresenter keyPresenter;
	
	String content;
	String uid;
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.close_icon:
			finish();
			break;
		case R.id.fankui_ok:
			content=fankui_et.getText().toString();
			showProgressDialog("提交中,请稍后", true);
			keyPresenter.getFankui(uid, content);
			break;

		default:
			break;
		}

	}

	@Override
	protected int layout_id() {
		return R.layout.activity_fan_kui;
	}

	@Override
	protected void onInitController() {

	}

	@Override
	protected void onInit() {
		setStatusBarHeight(v_statusbar);
		add_shap_title_tv.setText("意见反馈");
		
		keyPresenter=new KeyPresenter(this);
		uid = SPUtils.get(this, null, SPContants.USER_ID, "") + "";

	}

	@Override
	protected void onReadIntent(Bundle bundle) {

	}

	@Override
	public void update(Observable observable, Object data) {
		ResultEntity entity = handlerError(data);
		if (entity != null) {
			if (entity.getEventType() == KeyPresenter.fankui_success) {
				ByAlert.alert(entity.getData());
			}
			if (entity.getEventType() == KeyPresenter.fankui_fail) {
				ByAlert.alert(entity.getData());
			}
		}
		try {
			closeProgressDialog();
		} catch (Exception e) {
		}
		
	}

}
